import request from "@/utils/request";
import { VUE_APP_API_URL } from "@/config";
import {WebSocket} from "@/utils/request";
/**
 * 设备信息 socket
 * @returns {*}
 */
export async function createSocket(userid) {
  return WebSocket("get","/Wx/"+userid);
}
/**
 * 首页
 * @returns {*}
 */
export function getHomeData(q) {
  return request.get("index/", q, { login: false });
}

/**
 * 文章 轮播列表
 * @returns {*}
 */
export function getArticleBanner() {
  return request.get("/article/banner/list", {}, { login: false });
}

/**
 * 文章分类列表
 * @returns {*}
 */
export function getArticleCategory() {
  return request.get("/article/category/list", {}, { login: false });
}

/**
 * 文章 热门列表
 * @returns {*}
 */
export function getArticleHotList() {
  return request.get("/article/hot/list", {}, { login: false });
}

/**
 * 文章列表
 * @returns {*}
 */
export function getArticleList(q) {
  return request.get("/article/list/", q, { login: false });
}

/**
 * 分享
 * @returns {*}
 */
export function getShare() {
  return request.get("/share", {}, { login: false });
}

/**
 * 文章详情
 * @returns {*}
 */
export function getArticleDetails(id) {
  return request.get("/article/details/" + id, {}, { login: false });
}

/**
 * 获取微信sdk配置
 * @returns {*}
 */
export function getWechatConfig() {
  return request.get(
    "/wechat/config",
    { url: location.href },
    { login: false }
  );
}

/**
 * 获取微信sdk配置
 * @returns {*}
 */
export function wechatAuth(code, spread, login_type) {
  return request.get(
    "/wechat/auth",
    { code, spread, login_type },
    { login: false }
  );
}
/**
 * 获取快递公司
 * @returns {*}
 */
export function getLogistics() {
  return request.get("/logistics", {}, { login: false });
}
/**
 * 获取快递公司
 * @returns {*}
 */
export function getPlayUrl() {
  return request.get("/getPlayUrl", {}, { login: false });
}

/**
 * 获取图片base64
 * @retins {*}
 * */
export function imageBase64(image, code) {
  return request.post(
    "/image_base64",
    { image: image, code: code },
    { login: false }
  );
}
/**
 * 通用上传文件（图片）
 * @param {Object} filePath 返回服务器上访问的图片地址
 */
export function uploadFile(filePath){
	uni.uploadFile({
		url:VUE_APP_API_URL+"/api/upload",
		   filePath: filePath,
	      name: 'file',
	      success(res) {
	       // 显示上传信息
	         console.log(res);
			// alert(JSON.stringify(res.data));
			var data =JSON.parse( res.data );
			// console.log(data.link)
		 
	      }
		
	})
}


/**
 * 文章分类列表
 * @returns {*}
 */
export function SportDataV1() {
  return request.get("/sportDataV1");
}
export function getMatchResultV1() {
  return request.get("/getMatchResultV1");
}
export function getMatchDataPageListV1() {
  return request.get("/getMatchDataPageListV1");
}
export function refreshMatchResultV1() {
  return request.get("/refreshMatchResultV1");
}
export function sharesave(data) {
  return request.post("/sharesave",data, { login: false });
}
export function shareget(data) {
  return request.get("/shareget?time=" + data);
}